package com.aihelp.androidtestdemo;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.aihelp.androidtestdemo.ui.XMLDemo;

/**
 * Activity.this  ： points to the instance of the Activity you are currently in.
 */
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Button btn1;
    LayoutInflater inflater;
    Context context;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = MainActivity.this;
        setContentView(R.layout.activity_main);
        btn1 = findViewById(R.id.btn_layout_demo);
        getOnClickLinstener();




    }

    private void getOnClickLinstener() {

        //this refers to your current object ，In your case you must have implemented the View.OnClickListener , and thats what it points to.
        btn1.setOnClickListener(this);

    }



    @Override
    public void onClick(View v) {
        int viewId = v.getId();
        Intent intent;
        switch (viewId) {
            case R.id.btn_layout_demo:
                //添加两种布局方式
                intent = new Intent(this, XMLDemo.class);
                startActivity(intent);
                break;

        }

    }
}
